/**
 * 策略成本数据
 */
import React  from 'react'
import style from './index.less'
import { DataNone} from '../../components'
import {Table} from 'antd';


const CostData =({
  tag,
  dispatch,
  location:{pathname,query},
  data,
  date,
  fundId,
  orderNo
})=>{
  const myProps={
    columns: data.title.map((item,i)=>({
          title: item.name,
          dataIndex: item.column,
          key: item.column,
          width:'14%'
        })),
    dataSource: data.data,
    rowKey:data.keyRow,
    rowClassName:(record, index)=>record.orderNo === orderNo ? "on" : '',
    onRowClick:(record, index, event)=> {
      if(record.orderNo!=orderNo){
        dispatch({
            type: `${tag}/changeRouter`,
            payload: {
              pathname,
              query:{
                date:date,
                fundId:fundId,
                orderNo:record.orderNo
              }
            }
          })
          //选中点击后的某行的样式切换
          document.querySelector('.impcost table .on').className="ant-table-row ant-table-row-level-0"
          event.target.parentElement.className="ant-table-row on ant-table-row-level-0"
      }

      },
    scroll:{
      y:data.data.length>5?220:false
    }
  }
  return (
              <div className={`table ${style.costData}`}>
                {
                  data?<Table {...myProps} pagination={false} size="small"/>: <DataNone />
                }
              </div>
        )
}

// CostData.propTypes={
// tag,
// dispatch,
// location:{pathname,query},
// data,
// date,
// fundId,
// orderNo
// }

export default CostData
